import request from '@/utils/request'

export function add(data) {
  return request({
    url: 'api/standardComponentLevel',
    method: 'post',
    data
  })
}

export function del(ids) {
  return request({
    url: 'api/standardComponentLevel/',
    method: 'delete',
    data: ids
  })
}

export function edit(data) {
  return request({
    url: 'api/standardComponentLevel',
    method: 'put',
    data
  })
}

// 获取构件管理树
export function queryAllByGroup(query) {
  return request({
    url: 'api/standardComponent/queryAllByGroup',
    method: 'get',
    params: query
  })
}

// 新增下级节点
export function addNode(data) {
  return request({
    url: 'api/standardComponent',
    method: 'post',
    data
  })
}

// 删除节点
export function delNode(ids) {
  return request({
    url: 'api/standardComponent/',
    method: 'delete',
    data: ids
  })
}

// 编辑节点
export function editNode(data) {
  return request({
    url: 'api/standardComponent',
    method: 'put',
    data
  })
}

// 拖拽叶子节点
export function exchangeUpdateComponentSorted(data) {
  return request({
    url: 'api/standardComponent/exchangeUpdateComponentSorted',
    method: 'post',
    data
  })
}

export default { add, edit, del, queryAllByGroup, addNode, delNode, editNode, exchangeUpdateComponentSorted }
